﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Brain.General
{
    public class GamerController : IGamerController
    {
        public GamerControllerOptions Options { get; set; }

        public Xbox360GamePadState GamePadState { get; set; }

        /// <summary>
        /// Information about the Character this Controller
        /// is using, such as habilities and speed
        /// </summary>
        public CharacterInfo CharacterInfo { get; set; }

        /// <summary>
        /// The last GameController State
        /// </summary>
        public GamerControllerState LastState { get; set; }

        /// <summary>
        /// If this Gamer Controller should update
        /// </summary>
        public bool ShouldUpdate { get; set; }
        /// <summary>
        /// If this Gamer Controller should draw
        /// </summary>
        public bool ShouldDraw { get; set; }

        public WorldObject WorldObject { get; set; }

        #region Managers

        public IGamerCamera Camera { get; set; }

        public IGamerControllerInputManager InputManager { get; set; }

        #endregion

        public GamerController(CharacterInfo info,GamerControllerOptions options)
        {
            ShouldUpdate = true;
            ShouldDraw = true;
            this.CharacterInfo = info;

            WorldObject = new WorldObject(info.ModelPlace);
            WorldObject.Rendering = WorldObjectRendering.Rendered;

            this.Options = options;
        }

        /// <summary>
        /// Updates the Gamer Controller's state
        /// </summary>
        public void Update()
        {
            if (InputManager != null)
            {
                this.LastState = InputManager.GetState();
            }

            WorldObject.Position = this.LastState.Position;
            WorldObject.RotationMatrix = this.LastState.RotationMatrix;
            WorldObject.Update();
        }
        public void Draw()
        {
            WorldObject.Draw();

            if (this.Camera != null)
            {
                this.Camera.Draw();
            }
        }



        public bool ShouldSerialize { get; set; }

        public void SerializeData(SerializationData parentData, string index)
        {
        }

        public void DeserializeData(SerializationData parentData, string index)
        {
        }

        public string Name { get; set; }




        public void DeserializedAll()
        {
        }
    }
}
